import {Injectable} from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class CheckloginService {
  public storage = window.localStorage;

  constructor() {
    this.storage.setItem('user', '');
  }

  // 检查登录
  checkLogin() {
    if (localStorage.user) {
      return true;
    } else {
      return false;
    }
  }

  // 添加用户
  addLogin(id) {
    this.storage.setItem('user', id);
  }

  // 注销用户
  delLogin() {
    // this.storage.removeItem('user');
    localStorage.clear();
  }
}
